package wang.yangziqing.app_kotlin.ui.activity

import android.support.v7.widget.Toolbar
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.find
import wang.yangziqing.app_kotlin.R
import wang.yangziqing.app_kotlin.base.BaseActivity
import wang.yangziqing.app_kotlin.utils.FragmentUtils
import wang.yangziqing.app_kotlin.utils.ToolBarManager

class MainActivity : BaseActivity(), ToolBarManager {
    //主界面实现的是一个toolbar的接口
    //这个接口没有toolbar
    //惰性加载
    override val toolbar by lazy {
        find<Toolbar>(R.id.toolbar)
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_main
    }

    override fun initData() {
        super.initData()
        initMainToolBar()

    }

    override fun initListener() {

        bottomBar.setOnTabSelectListener {
            val beginTransaction = supportFragmentManager.beginTransaction()
            beginTransaction.replace(R.id.container,FragmentUtils.fragmentUtils.getFragment(it),it.toString())
            beginTransaction.commit()
        }

    }
}
